<template>

<div>
  <el-row>
    <mu-appbar title="数据信息" style="background-color:#409EFF">
      <mu-icon-button  icon="arrow_back_ios" slot="left" :to="{name: 'AgentInfoMenu' }"/>
    </mu-appbar>
  </el-row>
  <el-row>
    <el-col :span="12">
    </el-col>
    <el-col :span="12">
      <i class="el-icon-arrow-down" style="float:right" @click="handleTools"></i>
    </el-col>
  </el-row>

  <div class= "tools" v-show="tools">
      <el-row>
        <el-col :xs="6" :sm="4" :md="3" :lg="3">
          代理ID
        </el-col>
        <el-col :xs="18" :sm="20" :md="21" :lg="21">
          <el-input v-model="condition.uid" size="mini" @blur="handleFind"></el-input>
        </el-col>
      </el-row>

      <!-- <el-row>
        <el-col :xs="6" :sm="6" :md="6" :lg="6">
          起始日期
        </el-col>
        <el-col :xs="18" :sm="18" :md="18" :lg="18">
          <el-date-picker
            v-model="condition.startDay"
            type="date"
            placeholder="选择起始日期"
            size="mini"
            value-format="yyyy-MM-dd"
            @change="handleFind">
          </el-date-picker>
        </el-col>
      </el-row>

      <el-row>
        <el-col :xs="6" :sm="6" :md="6" :lg="6">
          结束日期
        </el-col>
        <el-col :xs="18" :sm="18" :md="18" :lg="18">
          <el-date-picker
            v-model="condition.endDay"
            type="date"
            placeholder="选择结束日期"
            size="mini"
            value-format="yyyy-MM-dd"
            @change="handleFind">
          </el-date-picker>
        </el-col>
      </el-row> -->
  </div>

  <div>
    <el-row>
      <el-table
        :data="tableData"
        style="width: 100%">
        <el-table-column
          prop="agentUid"
          label="代理ID">
        </el-table-column>
        <el-table-column
          prop="binderUid"
          label="上级ID">
        </el-table-column>
        <!-- <el-table-column
          v-if="!this.isAgent"
          prop="organizer"
          label="顶级ID">
        </el-table-column> -->
        <el-table-column
          prop="organizer"
          label="姓名">
        </el-table-column>
        <el-table-column
          prop="wechat"
          label="昵称">
        </el-table-column>
        <el-table-column
          prop="recNdot"
          label="今日领取">
        </el-table-column>
        <el-table-column
          prop="leftNdot"
          label="未领取">
        </el-table-column>
        <el-table-column
          prop="recTime"
          label="领取时间">
        </el-table-column>
      </el-table>
    </el-row>

    <el-row>
      <center>
        <el-pagination
          small
          layout="prev, pager, next"
          :total="condition.total"
          :page-size="condition.pageSize"
          :current-page="condition.currentPage"
          @current-change="handleCurrentChange">
        </el-pagination>
      </center>
    </el-row>
  </div>

</div>
</template>

<style scoped>
  .el-row {
    margin-bottom: 16px;
  }
  .el-col {
    margin-bottom: 8px;
  }
</style>

<script>
  export default {
    data () {
      return {
        tools: true,
        tableData5: [],
        tableData3: [],
        condition: {
          // startDay: this.$time.getDateBefore(new Date(), -3),
          // endDay: this.$time.getDateBefore(new Date(), 0),
          uid: '',
          currentPage: 1,
          pageSize: 10,
          total: 0,
          account: sessionStorage.getItem('account')
        },
        isAgent: false
      }
    },
    methods: {
      handleTools () {
        if (this.tools) {
          this.tools = false
        } else {
          this.tools = true
        }
      },
      handleFind () {
        let that = this
        if (this.condition.uid === '' || this.condition.uid.length === 0) {
          this.condition.uid = -1
        }
        this.$axios({
          method: 'get',
          url: '/api/AgentService.getTodayAgentData',
          params: this.condition
        })
        .then(function (resp) {
          that.initCondition()
          that.tableData = resp.data.data
          that.condition.total = resp.data.page.total
        })
      },
      initCondition () {
        this.condition.uid = ''
      },
      init () {
        this.handleFind()
      },
      handleCurrentChange (val) {
        this.condition.currentPage = val
        this.handleFind()
      }
    },
    mounted () {
      if (sessionStorage.getItem('role') === 'agent') {
        this.isAgent = true
      }
      this.init()
    }
  }
</script>
